package tp.pr4.listeners;

import tp.pr4.Direction;
import tp.pr4.Place;

public interface NavigationModuleListener {
	/**
	 * Function is called when the rotation of the module changes. The new facing direction is sent as a parameter 
	 * @param newDirection
	 */
	public void onRotationChanged(Direction newDirection);
	/**
	 * Functions is called when the module moves successfully. It won't trigger when it doesn't move but attemps to.
	 * Function might be also triggered by petition updates, in which case newPlace == oldPlace
	 * @param newPlace
	 * @param oldPlace
	 * @param movingDirection
	 */
	public void onMove(Place newPlace, Place oldPlace, Direction movingDirection);
	/**
	 * Function will be called after onMove() when the space ship is reached
	 */
	public void onSpaceShipReached();
	
	/**
	 * Called when the robot tries to move but crashes against a wall
	 * @param movingDirection direction it was trying to move to
	 * @param type Type of crash as specified by NavigationModuleListener's constants: ON_NOSTREET_CRASH, ON_CLOSEDSTREET_CRASH
	 */
	public void onCrash(Direction movingDirection, int type);
	
	/**
	 * Called when a door has its state toggled, in a direction dir.
	 * @param dir
	 * @param wasOpened true if it was opened, false if not
	 * @param p the place where the door was toggled
	 */
	public void onDoorToggled(Direction dir, boolean wasOpened, Place p);
	
	public static final int ON_NOSTREET_CRASH = 1;
	public static final int ON_CLOSEDSTREET_CRASH = 2;
	
}
